<template>
  <tinymce :height="300" v-model="content" menubar="false" @save="save"/>
</template>

<script>
import Tinymce from '@/components/Tinymce'
import { parseChiefComplaint, parseHPI, parsePastHistory, parsePE, parseCheckout, parseDiagnosis } from '@/utils/index'
import { getTemplate, saveTemplate } from '@/api/print'

export default {
  components: { Tinymce },
  data() {
    return {
      content: ''
    }
  },
  methods: {
    save() {
      let _confirm = confirm('确认保存?')
      if (_confirm == true) {
        saveTemplate(this.content).then(res => {
        if (res.data.result == 'success') {
            alert('保存成功')
          }
        })
      }
    }
  },
  mounted() {
    getTemplate(this.templateOwnerType, this.templateOwner).then(res => {
      this.content = res.data.template
    })
  },
  computed: {
    templateOwnerType: function() {
      return this.$route.query.templateOwnerType
    },
    templateOwner: function() {
      return this.$route.query.templateOwner
    }
    // content: {
    //   get() {
    //     return `<h1 style=\"text-align: center;\">杭州市富阳区第一人民医院</h1>
    //     <h1 style=\"text-align: center;\">门诊病历</h1>
    //     <p><strong>姓名:</strong>${tempOpen.patientInfo.patientName.value}&nbsp; &nbsp; &nbsp; &nbsp; <strong>性别:</strong>${tempOpen.patientInfo.sex.value}&nbsp; &nbsp; &nbsp; &nbsp; <strong>就诊卡号:</strong>${tempOpen.patientInfo.medicareId.value}</p>
    //     <p><strong>诊断:</strong>${parsedDiagnosis}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <strong>血压:</strong>${tempOpen.patientInfo.sbp.value}/${tempOpen.patientInfo.dbp.value}mmHg&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <strong>脉搏:</strong>${tempOpen.patientInfo.pulse.value}次/分</p>
    //     <p><strong>就诊日期:</strong>${tempOpen.datetime}&nbsp; &nbsp; &nbsp; &nbsp; <strong>就诊医生:</strong>${tempOpen.doctorName}<strong>&nbsp; &nbsp; &nbsp; &nbsp; 就诊科室:</strong>${tempOpen.deptName}<strong>&nbsp; &nbsp; &nbsp; &nbsp; 病人去向:</strong></p>
    //     <hr />
    //     <span><strong>病人主诉:</strong></span><span><p>${parsedChiefComplaint}</p></span>
    //     <p><strong>现病史:</strong>${parsedHPI}</p>
    //     <p><strong>体格检查:</strong>${parsedPE}</p>
    //     <p><strong>检查检验:</strong>${parsedCheckout}</p>
    //     <p>&nbsp;</p>
    //     <p><strong>既往史:</strong>${parsedPastHistory}</p>
    //     <p style=\"text-align: right;\">医生签名:<span style=\"text-decoration: underline;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></p>`
    //   },
    //   set(newVal) {
    //   }
    // }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
p {
  font-size: initial;
}
h1 {
  text-align: center;
}
</style>